import {checkUsername , checkPassword} from './utils.js'
import "./css/index.css";
import "./less/index.less";
import axios  from 'axios';

console.log(checkUsername('ccccc'))
console.log(checkPassword('121212'))

// document.querySelector('.login-btn').addEventListener('click',()=>{
//     const username=document.querySelector('.username').value
//     const password=document.querySelector('.password').value

//     if(!checkUsername(username)) {
//         return alert('用户名必须大于等于8位')
//     }
//     if(!checkPassword(password)) {
//         return alert('密码必须大于等于6位')
//     }

//    alert('注册成功')
// })

import imgObj from './assets/logo.png'
document.querySelector('.logo-img').src=imgObj

const arr =[1,2,3,4,5]
const newArr =arr.map(item=>item+1)
console.log(newArr)
console.logg(66666)

document.querySelector('.login-btn').addEventListener('click',()=>{
    const username=document.querySelector('.username').value
    const password=document.querySelector('.password').value

    if(!checkUsername(username)) {
        return alert('用户名必须大于等于8位')
    }
    if(!checkPassword(password)) {
        return alert('密码必须大于等于6位')
    }

//    alert('注册成功')
   axios({
    url:'http://ajax-api.itheima.net/register',
    method:'post',
    data:{
       username,
       password
    }

   }).then(res=>{
    alert(res.data.message)
   }).catch(err=>{
    alert(err.response.data.message)
   })

})
